from gui import gui

class application_window_fake :
    def __init__ ( self ) :
        self . _icon = None
        self . _title = None
        self . _main_loop_running = None
        self . _application_quited = None
        self . _bind_all_event = None
        self . _bind_all_handler = None
        self . _bind_event = None
        self . _bind_handler = None
        self . _background = None
        self . _cget = { }
        self . _focused = None
    def wm_iconbitmap ( self , icon ) :
        self . _icon = icon
    def wm_title ( self , title ) :
        self . _title = title
    def mainloop ( self ) :
        self . _main_loop_running = True
    def quit ( self ) :
        self . _application_quited = True
    def bind_all ( self , event , handler ) :
        self . _bind_all_event = event
        self . _bind_all_handler = handler
    def bind ( self , event , handler ) :
        self . _bind_event = event
        self . _bind_handler = handler
    def configure ( self , _fake_arg = None , background = None ) :
        self . _background = background
    def cget ( self , option ) :
        return self . _cget [ option ]
    def focus ( self ) :
        self . _focused = True

class tkinter_fake :
    def __init__ ( self ) :
        self . _application_windows = [ ]
    def Tk ( self ) :
        window = application_window_fake ( )
        self . _application_windows += [ window ]
        return window

class mediator_fake :
    def __init__ ( self ) :
        self . _gui_create_application_window_reply = None
    def gui_create_application_window_reply ( self , window ) :
        self . _gui_create_application_window_reply = window 

class gui_application_tests :
    'gui_application'
    def __init__ ( self , test ) :
        self . _test = test
        self . _tkinter = tkinter_fake ( )
        self . _mediator = mediator_fake ( )
        self . _gui = gui ( mediator = self . _mediator , tkinter = self . _tkinter , tkfont = None , scheduler = None )        
    def test_gui_create_application_window ( self ) :
        self . _gui . gui_create_application_window_request ( )
        self . _test . assume_equal_len ( self . _tkinter . _application_windows , 1 )
    def test_gui_set_application_window_icon ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_set_application_window_icon ( window , 'my icon' )
        self . _test . assume_equal ( self . _tkinter . _application_windows [ 0 ] . _icon , 'my icon' )
    def test_gui_create_application_window_encapsulation ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _test . assume_not_equal ( self . _tkinter . _application_windows , [ window ] )
    def test_gui_set_application_window_title ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_set_application_window_title ( window , 'my title' )
        self . _test . assume_equal ( self . _tkinter . _application_windows [ 0 ] . _title , 'my title' )
    def test_gui_run_main_application_loop ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_run_main_application_loop ( window )
        self . _test . assume_true ( self . _tkinter . _application_windows [ 0 ] . _main_loop_running )
    def test_gui_quit_application ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_quit_application ( window )
        self . _test . assume_true ( self . _tkinter . _application_windows [ 0 ] . _application_quited )
